"""
输入一个文件名,统计文件中代码行数、注释行数、空行数
并输出代码以及注释
"""

file = input("请输入文件名：")

code_lines = 0
comment_lines = 0
blank_lines = 0

with open(file, 'r', encoding='utf-8') as f:
    lines = f.readlines()
    for line in lines:
        line = line.strip()
        if line.startswith('#'):
            comment_lines += 1
        elif line == "":
            blank_lines += 1
        else:
            code_lines += 1

print(
    "代码行数:{} 注释行数:{} 空行数:{}".format(
        code_lines,
        comment_lines,
        blank_lines
    )
)
